package com.jams.goodox.entity;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.jams.goodox.activity.home.SubmitBean;
import com.jams.goodox.net.BaseEntity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/26.
 */

public class GoodBuyBean extends BaseEntity{

    private Address address;
    private String payType;
    private String transit;
    private String note;
    private  List<Data> productList;

    public List<Data> getProductList() {
        return productList;
    }

    public void setProductList(List<Data> productList) {
        this.productList = productList;
    }

    private List<Data> data;

    public List<Data> getData() {
        return data;
    }

    public void setData(List<Data> data) {
        this.data = data;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }

    public String getTransit() {
        return transit;
    }

    public void setTransit(String transit) {
        this.transit = transit;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public static class Data implements Serializable{
        private String id;
        private String productid;
        private String title;
        private String preview;
        private String price;
        private String num;
        private String time;
        private List<OptionBean> sb;
        private boolean isChoose;
        private double oldAllMoney;

        public SubmitBean.SubmitDataBean transForData(){
            SubmitBean.SubmitDataBean dataBean=new SubmitBean.SubmitDataBean();
            dataBean.setId(id);
            dataBean.setProductid(productid);
            dataBean.setTitle(title);
            dataBean.setPreview(preview);
            dataBean.setPrice(price);
            dataBean.setNum(num);
            dataBean.setTime(time);
            return dataBean;
        }

        public List<JsonObject> transFor(){
            List<JsonObject> list=new ArrayList<>();
            if (sb==null)return list;
            for(OptionBean optionBean:sb){
                JsonObject jsonObject=new JsonObject();
                jsonObject.add(optionBean.getOptionKey(),new Gson().toJsonTree(optionBean));
                list.add(jsonObject);
            }
            return list;
        }

        public boolean isChoose() {
            return isChoose;
        }

        public void setChoose(boolean choose) {
            isChoose = choose;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getProductid() {
            return productid;
        }

        public void setProductid(String productid) {
            this.productid = productid;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPreview() {
            return preview;
        }

        public void setPreview(String preview) {
            this.preview = preview;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public String getTime() {
            return time;
        }

        public void setTime(String time) {
            this.time = time;
        }

        public double getAllMoney() {
            return oldAllMoney;
        }

        public void setAllMoney(double allMoney) {
            this.oldAllMoney = allMoney;
        }

        public List<OptionBean> getOption() {
            return sb;
        }

        public void setOption(List<OptionBean> option) {
            this.sb = option;
        }

        private List<String> optionStr;

        public List<String> getOptionStr() {
            return optionStr;
        }

        public void setOptionStr(List<String> optionStr) {
            this.optionStr = optionStr;
        }

        public static class OptionBean implements Serializable {
            String name;
            String price;
            String optionKey;

            public String getOptionKey() {
                return optionKey;
            }

            public void setOptionKey(String optionKey) {
                this.optionKey = optionKey;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getPrice() {
                return price;
            }

            public void setPrice(String price) {
                this.price = price;
            }
        }
    }

}
